﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ENT.GP.Datos.MysqlHelper;
using System.Data;
using System.Web.UI.DataVisualization.Charting;
using Coolite.Ext.Web;
using entgp.Code;

public partial class Estadisticas_wucEstadisticas : System.Web.UI.UserControl
{

    HelperMySql my = HelperMySql.ObtenerConexion("");
    DataSet proyectos = new DataSet();

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Chart1_Click(object sender, ImageMapEventArgs e)
    {
        UtilP.MostrarNotificacion(String.Format("Seleccionado: {0}", e.PostBackValue), "aviso", MessageBox.Icon.INFO);
        //Label1.Text = String.Format("Seleccionado: {0}", e.PostBackValue);
        Chart1.Series["Series1"].ChartType = SeriesChartType.Column;
        Chart1.DataBind();
    }

    public void btnEjesProyectos_Click(object sender, EventArgs e)
    {
        proyectos = my.EjecutarStoreProcedure("SELECT NOMBREPROYECTO,COSTOTOTAL FROM entpm_proyecto");

        this.Chart1.Series[0].PostBackValue = "#AXISLABEL";
        this.Chart1.Series[0].ToolTip = "#AXISLABEL Region: #VAL{0} US";

        // Set chart data source
        Chart1.DataSource = proyectos;

        // Set series members names for the X and Y values 
        Chart1.Series["Series1"].XValueMember = "NOMBREPROYECTO";
        Chart1.Series["Series1"].YValueMembers = "COSTOTOTAL";
        
        // Set series chart type
        Chart1.Series["Series1"].ChartType = SeriesChartType.Pie;

        // Data bind to the selected data source
        Chart1.DataBind();
        Chart1.SaveImage(MapPath("~/resources/img1/foto1.jpg"), ChartImageFormat.Jpeg);
    }

    public void btnEjesMontos_Click(object sender, EventArgs e)
    {
        proyectos = my.EjecutarStoreProcedure("SELECT NOMBREPROYECTO,COSTOTOTAL FROM entpm_proyecto");

        this.Chart1.Series[0].PostBackValue = "#AXISLABEL";
        this.Chart1.Series[0].ToolTip = "#AXISLABEL Region: #VAL{0} US";

        // Set chart data source
        Chart1.DataSource = proyectos;

        // Set series members names for the X and Y values 
        Chart1.Series["Series1"].XValueMember = "NOMBREPROYECTO";
        Chart1.Series["Series1"].YValueMembers = "COSTOTOTAL";

        // Set series chart type
        Chart1.Series["Series1"].ChartType = SeriesChartType.Column;

        // Set drawing style
        Chart1.Series["Series1"]["DrawingStyle"] = "LightToDark";

        // Set point width of the series
        Chart1.Series["Series1"]["PointWidth"] = "0.8";

        // Data bind to the selected data source
        Chart1.DataBind();
        Chart1.SaveImage(MapPath("~/resources/img1/foto2.jpg"), ChartImageFormat.Jpeg);
    }

    public void btnDesembolsosMes_Click(object sender, EventArgs e)
    {
        proyectos = my.EjecutarStoreProcedure("SELECT NOMBREPROYECTO,COSTOTOTAL FROM entpm_proyecto");

        this.Chart1.Series[0].PostBackValue = "#AXISLABEL";
        this.Chart1.Series[0].ToolTip = "#AXISLABEL Region: #VAL{0} US";

        // Set chart data source
        Chart1.DataSource = proyectos;

        // Set series members names for the X and Y values 
        Chart1.Series["Series1"].XValueMember = "NOMBREPROYECTO";   //meses
        Chart1.Series["Series1"].YValueMembers = "COSTOTOTAL";     //desembolsos

        // Set series chart type
        Chart1.Series["Series1"].ChartType = SeriesChartType.Line;
        Chart1.Series["Series1"].MarkerStyle = MarkerStyle.Star5;
        Chart1.Series["Series1"].MarkerSize = 10;
        Chart1.Series["Series1"].BorderWidth = 5;

        // Set point labels
        Chart1.Series["Series1"].IsValueShownAsLabel = true;

        // Enable X axis margin
        Chart1.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = true;

        // Data bind to the selected data source
        Chart1.DataBind();
        Chart1.SaveImage(MapPath("~/resources/img1/foto3.jpg"), ChartImageFormat.Jpeg);
    }
}
